Array.prototype.remove = function(val) {
	var index = -1;
	if (!Array.prototype.indexOf) {
		for ( var i = 0; i < this.length; i++) {
			if (this[i] == val) {
				index = i;
				break;
			}
		}
	}
	if (index < 0) {
		index = this.indexOf(val);
	}
	if (index > -1) {
		this.splice(index, 1);
	}
};

Array.prototype.contains = function(val) {
	return RegExp("(^|,)" + val.toString() + "($|,)").test(this);
};

/**
 * example:var d = new Date().format('yyyy-MM-dd');
 */
Date.prototype.format = function(format) {
	var o = {
		"M+" : this.getMonth() + 1, // month
		"d+" : this.getDate(), // day
		"h+" : this.getHours(), // hour
		"m+" : this.getMinutes(), // minute
		"s+" : this.getSeconds(), // second
		"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
		"S" : this.getMilliseconds()
	// millisecond
	}
	if (/(y+)/.test(format))
		format = format.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	for ( var k in o)
		if (new RegExp("(" + k + ")").test(format))
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
					: ("00" + o[k]).substr(("" + o[k]).length));
	return format;
}
var SeriesColor = {
	"newUser" : "#4b81bd",
	"dau" : "#417abd",
	"startupUser" : "#c6da9f",
	"startupCount" : "#6d0f0f",
	"wakeupUser" : "#429eb3",
	"wakeupCount" : "#452f60",
	"useUser" : "#ce996f",
	"useCount" : "#81a0cf",
	"pv" : "#122232",
	"puv" : "#2f7fd8",
	"vv" : "#c42525",
	"vvLinearRegression" : "#a6c96a",
	"newUserNumLinearRegression" : "#a6c95b",
	"vvPredict" : "#cc6666",
	"realVV" : "#2f7ed8",
	"fuv" : "#0d233a",
	"realFuv" : "#8bbc21",
	"playTime" : "#910000",
	"stock" : "#8B008B",
	"consume" : "#7CCD7C",
	"consumeRate" : "#00EEEE",
	"nonInnerConsume" : "#4876FF",
	"nonInnerProp" : "#EEEE00",
	"innerConsume" : "#EE9A00",
	"innerProp" : "#D8BFD8",
	"commercialVv" : "#008B45",
	"stockLinearRegression" : "#B3EE3A"
}

function getContextPath() {
	if (window.parent) {
		return window.parent.getSystemContextPath();
	}
}

function isEmpty(value) {
	if (value === null || value === undefined || value === "null"
			|| value === 'null' || typeof (value) == "undefined"
			|| value === '' || value === "" || value.length == 0) {

		return true;

	} else {
		return false;
	}
}
